package com.zzty.zzlp.dao;

import com.zzty.zzlp.entity.Question;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface QuestionMapper {
    @Insert("Insert into question (content) values(#{content})")
    int insertQue(@Param("content") String content);

    @Select("select count(*) from question")
    Integer count();

    @Select("select * from question order by id limit #{Num1},#{Num2}")
    List<Question> selectAll(@Param("Num1") Integer Num1, @Param("Num2") Integer Num2);

    @Select("select id from question where content=#{content} order by id desc limit 1")
    Integer selectQueId(String content);

    @Select("select * from question where id=#{id}")
    Question selectQuecontent(@Param("id") String id);

    @Insert("INSERT INTO selfexam (date,questions,clazzId) VALUES (#{date},#{questions},#{clazzId})")
    public Integer searchNewId(@Param("date") String date, @Param("questions") String questions,
                               @Param("clazzId") Integer clazzId);

    @Select("select id from selfexam where clazzId=#{clazzId} order by date desc limit 1")
    Integer selectLastSelfId(@Param("clazzId") Integer clazzId);


    @Select("select id from selfexam where clazzId=#{clazzId} order by date desc limit 1")
    Integer LastSelfId(@Param("clazzId") Integer clazzId);

    @Select("select id from teamexam where clazzId=#{clazzId} order by date desc limit 1")
    Integer selectLastTeamId(@Param("clazzId") Integer clazzId);

    @Insert("INSERT INTO teamexam (date,questions,clazzId) VALUES (#{date},#{questions},#{clazzId})")
    public Integer searchNewId1(@Param("date") String date, @Param("questions") String questions,
                                @Param("clazzId") Integer clazzId);

    @Select("select id from user where clazzid=#{clazzid} and type is #{type}")
    List<Integer> selectStuId(@Param("clazzId") Integer clazzId, @Param("type") Integer type);

    @Insert("insert into selfexamtransation(examId,userId) values (#{examId},#{userId})")
    Integer insertselfexamtransation(@Param("examId") Integer examId, @Param("userId") Integer userId);

    @Select("select stu_ids from classgroup where class_id=#{class_id} order by id desc limit #{id}")
    List<String> selectstu_ids(@Param("id") Integer id, @Param("class_id") Integer class_id);

    @Insert("insert into teamexamtransation(examId,userIds) values (#{examId},#{userIds})")
    Integer insertteamexamtransation(@Param("examId") Integer examId, @Param("userIds") Integer userIds);

}
